/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.sql.Timestamp;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;

/**
 *
 * @author Ee Ting
 */
@Entity
public class MRPRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long mrpId;
    
    private int week;
    private int month;
    private int year;
    private int grossRequirements;
    private int scheduledReceipts;
    private int plannedReceipts;
    private int onHandInitial;
    private int onHand;
    private int plannedOrders;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private SystemUser createdBy;
    private Timestamp createdDate;
    
    @OneToOne(cascade={CascadeType.PERSIST})
    private Component comp;
    
    @OneToOne(cascade={CascadeType.PERSIST})
    private ProdRecordMRP mrpWeek;
    
    @OneToOne(cascade={CascadeType.PERSIST})
    private MPSWeeklyRecord mps;
    
    public void create(int wk, int mth, int yr, int gr, int sr, int pr, int ohi, int oh, int po, SystemUser user)
    {
        this.setWeek(wk);
        this.setMonth(mth);
        this.setYear(yr);
        this.setGrossRequirements(gr);
        this.setScheduledReceipts(sr);
        this.setPlannedReceipts(pr);
        this.setPlannedOrders(po);
        this.setOnHandInitial(ohi);
        this.setOnHand(oh);
        this.setCreatedBy(user);
        java.util.Date tmp = new java.util.Date();
        this.setCreatedDate(new Timestamp(tmp.getTime()));
    }

    public SystemUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(SystemUser createdBy) {
        this.createdBy = createdBy;
    }

    public Timestamp getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }
    

    public Component getComp() {
        return comp;
    }

    public void setComp(Component comp) {
        this.comp = comp;
    }

    public int getGrossRequirements() {
        return grossRequirements;
    }

    public void setGrossRequirements(int grossRequirements) {
        this.grossRequirements = grossRequirements;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public ProdRecordMRP getMrpWeek() {
        return mrpWeek;
    }

    public void setMrpWeek(ProdRecordMRP mrpWeek) {
        this.mrpWeek = mrpWeek;
    }

    public int getOnHand() {
        return onHand;
    }

    public void setOnHand(int onHand) {
        this.onHand = onHand;
    }

    public int getOnHandInitial() {
        return onHandInitial;
    }

    public void setOnHandInitial(int onHandInitial) {
        this.onHandInitial = onHandInitial;
    }

    public int getPlannedOrders() {
        return plannedOrders;
    }

    public void setPlannedOrders(int plannedOrders) {
        this.plannedOrders = plannedOrders;
    }

    public int getPlannedReceipts() {
        return plannedReceipts;
    }

    public void setPlannedReceipts(int plannedReceipts) {
        this.plannedReceipts = plannedReceipts;
    }

    public int getScheduledReceipts() {
        return scheduledReceipts;
    }

    public void setScheduledReceipts(int scheduledReceipts) {
        this.scheduledReceipts = scheduledReceipts;
    }

    public int getWeek() {
        return week;
    }

    public void setWeek(int week) {
        this.week = week;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public Long getMrpId() {
        return mrpId;
    }

    public void setMrpId(Long id) {
        this.mrpId = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (mrpId != null ? mrpId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MRPRecord)) {
            return false;
        }
        MRPRecord other = (MRPRecord) object;
        if ((this.mrpId == null && other.mrpId != null) || (this.mrpId != null && !this.mrpId.equals(other.mrpId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.MPRRecord[ id=" + mrpId + " ]";
    }
    
}
